package naf
{
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	import flash.geom.Rectangle;
	import flash.utils.ByteArray;
	
	//import org.serialization.bson.BSON;
	
	import png.PngFileInfo;
	
	public class NafPngProxy
	{
		private var _obj:Object;
		private var _pngFileInfo:PngFileInfo;
		
		public function NafPngProxy()
		{
		}
		
		public function open( file:File ):void
		{
			/*
			var fs:FileStream = new FileStream();
			fs.open( file, FileMode.READ )
			var byteArray:ByteArray = new ByteArray();
			fs.readBytes( byteArray, 0, file.size );
			fs.close();
			
			_obj = BSON.decode( byteArray );
			*/
		}
		
		public function get pngFileInfo():PngFileInfo
		{
			_pngFileInfo= new PngFileInfo;
			//_pngFileInfo.openFromByteArray( pngData )
			return _pngFileInfo;
		}
		
		public function get pngData():ByteArray
		{
			if("textureAtlas" in _obj == false)
				throw new Error("old version");
			return _obj["textureAtlas"][1].data;
		}
		
		public function set pngData( value:ByteArray ):void
		{
			//_obj["textureAtlas"][1].data = value;
		}
		
		public function saveAsPng( file:File ):void
		{
			/*
			var fs:FileStream = new FileStream
			fs.open( file, FileMode.WRITE );
			fs.writeBytes( pngData, 0, pngData.length );
			fs.close();
			*/
		}
		
		public function saveAsNaf( file:File ):void
		{
			/*
			var byteArr:ByteArray =  BSON.encode( _obj );
			var fs:FileStream = new FileStream
			fs.open( file, FileMode.WRITE );
			fs.writeBytes( byteArr, 0, byteArr.length );
			fs.close();
			*/
		}
	}
}